<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        window.onload = function () {
            var btn = document.getElementsByTagName('input')[0];
            var reg = /(bad)|[\u4e00-\u9fa5]/gi;
            btn.onclick = function () {
                var str = document.getElementsByTagName('textarea')[0].value;
                var newStr = str.replace(reg, '*');
                document.getElementsByTagName('textarea')[1].innerHTML = newStr;
            }
        }
    </script>
</head>
<body>
<div>
    过滤前：<br><br>
    <textarea id="pre" rows="10" cols="40"></textarea>
</div>
<input id="btn" type="button" value="过滤"/>
<div>
    过滤后：<br><br>
    <textarea id="res" rows="10" cols="40"></textarea>
</div>
</body>
</html>